import 'package:flutter/material.dart';

class SampleSnackBarWidget extends StatelessWidget {
  const SampleSnackBarWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("SampleSnackBar"),
        ),
        body: _SampleSnackBarWidget(),
      ),
    );
  }
}

class _SampleSnackBarWidget extends StatefulWidget {
  const _SampleSnackBarWidget({Key? key}) : super(key: key);

  @override
  _SampleSnackBarWidgetState createState() => _SampleSnackBarWidgetState();
}

class _SampleSnackBarWidgetState extends State<_SampleSnackBarWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: RaisedButton(
        onPressed: () {
          Scaffold.of(context).showSnackBar(SnackBar(
            backgroundColor: Colors.red,
            elevation: 8,
            shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(100)),
            // content: Text("光辉岁月"),
            content: Row(
              children: [Icon(Icons.check, color: Colors.green), Text('下载成功')],
            ),
            duration: Duration(seconds: 1),
          ));
        },
        child: Text("消息提醒"),
      ),
    );
  }
}
